<template>
  <div class="free">
    <Loading v-show="this.$store.state.isLoading" />
    <div class="container">
      <swipe :banners="banners"></swipe>
      <List2 :obj="goodBook" @gotoContent="afterClick"></List2>
      <List2 :obj="mayLike" @gotoContent="afterClick"></List2>
    </div>
  </div>
</template>

<script>
import { getStoreData } from "@/request/api";
import List2 from "@/components/List2";
import Swipe from "../components/swipe.vue";
export default {
  components: {
    List2,
    Swipe,
  },
  data() {
    return {
      //好书专区
      goodBook: {
        list: [],
        name: "",
      },
      //猜你喜欢
      mayLike: {
        list: [],
        name: "",
      },
      banners: [],
    };
  },
  methods: {
    afterClick(obj) {
      this.$router.push(
        "/content?source_uuid=" + obj.id + "&title=" + obj.title
      );
    },
  },
  mounted() {
    getStoreData({
      type: this.$route.query.type,
      uuid: this.$route.query.uuid,
    }).then((res) => {
      if (res.resCode == 0) {
        let list = res.data.list;
        if (list[0].banners.length > 0) {
          this.banners = list[0].banners;
        } else if (list[0].list.length > 0) {
          this.goodBook = list[0];
        }

        this.mayLike = list[1];
      }
    });
  },
};
</script>

<style lang="scss" scoped>
.free {
  width: 100%;
  overflow: hidden;
}
</style>